import { observable, action } from '@/miniprogram_npm/mobx-miniprogram/index';

const PredictStore = observable({
    tableData: [], // 预测数据表格数据
    predictTempFile: null, // 预测源文件
    predictResult: [], // 预测结果

    setTableData: action(function (payload) {
        this.tableData = payload;
    }),

    setPredictTempFile: action(function (payload) {
        this.predictTempFile = payload;
    }),

    setPredictResult: action(function (payload) {
        this.predictResult = payload;
    }),

    resetAll: action(function () {
        this.tableData = [];
        this.predictTempFile = null;
        this.predictResult = [];
    }),

    getPredictTempFile() {
        return this.predictTempFile;
    },

    getPredictResult(size) {
        return this.predictResult.slice(0, size) ?? [];
    }
});

export default PredictStore;
